
/*
 * NewJFrame.java
 *
 * Created on 2009-11-19, 10:45:11
 */
/**
 *
 * @author Hongya Xing
 */
 import java.awt.Font;
 import java.io.IOException;
 
public class NewJFrame extends javax.swing.JFrame{

    /** Creates new form NewJFrame */
    public NewJFrame(){
        initComponents();
    }


    /** This method is called from within the constructor to
     * initialize the form.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jButton1 = new javax.swing.JButton();//Creates "debug" button
        jButton2 = new javax.swing.JButton();//Creates "transform" button
        jButton3 = new javax.swing.JButton();//Creates "clear" button
        textArea1 = new java.awt.TextArea();//Creates the display area which shows the information about every processes
        textArea2 = new java.awt.TextArea();//Creates the edit area

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        /**
         * Edits every parameter of Debug button including position, text and so on.
         */
        jButton1.setText("Debug");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        /**
         * Edits every parameter of Transform button including position, text and so on.
         */
        jButton2.setText("Transform");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try 
                  {
                	jButton2ActionPerformed(evt);
                	}
                	catch(IOException e)
                	{
                      System.out.println("File Error!");
                	}
            }
        });
        textArea1.setEditable(false);//Makes display area uneditable.
        Font stringFont = new Font("arial",Font.PLAIN,20);
        textArea1.setFont(stringFont);
        textArea2.setFont(stringFont);
        /**
         * Edits every parameter of Clear button including position, text and so on.
         */
        jButton3.setText("Clear");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt){
                jButton3ActionPerformed(evt);
            }
        });

        /**
         * Edits every parameter of whole GUI including position, text, size and so on.
         * I don't fully understand some of codes since This part was made by NetBeans.
         * So, the comments for details are elided.
         */
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(textArea2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
                    .addComponent(textArea1, javax.swing.GroupLayout.PREFERRED_SIZE, 520, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(25, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(83, 83, 83)
                .addComponent(jButton1)
                .addGap(127, 127, 127)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE)
                .addComponent(jButton3)
                .addGap(66, 66, 66))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(textArea2, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(25, 25, 25)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addGap(27, 27, 27)
                .addComponent(textArea1, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>
    
    /**
     * Adds action for Transform button.
     * First, gets the texts in edit area into string. Then, uses translate method.
     */
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) throws IOException{
    	  String n;
    	  n=textArea2.getText();
    	  translate(n);
    }

    /**
     * Adds action for Debug button.
     * First, gets the texts in edit area into string. Then, uses debug method.
     */
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)  {
        String n;
        n=textArea2.getText();
        debug(n);
      
    }

    /**
     * Adds action for Clear button.
     * Just sets the text in display area and edit area into nothing.
     */
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
        textArea1.setText("");
        textArea2.setText("");
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private java.awt.TextArea textArea1;
    private java.awt.TextArea textArea2;
    // End of variables declaration
    
    /**
     * used to debug the error
     * 
     */
    public void debug(String a) 
	{
	
		CodeProcess_Control d = new CodeProcess_Control(a);
		

	  
	}

    /**
     * translate the command to hex number
     * 
     */
    public void translate(String s) throws IOException
    {
	     //TranslateProcess d=new TranslateProcess(s);
	    // d.process();
	    // String errorMessage = d.getErrorMessage();

		
		//else
			 // textArea1.append(errorMessage);
    }



}